﻿Imports System.Xml.Serialization

Namespace Commands
    Public Class CancelFilePartRequest
        Inherits Framework.Net.CommandBase

        Private Const mRequestCode As String = "CancelUploadFilePart"
        Private Const mReplyCode As String = Nothing

        Public Sub New()
            MyBase.New(mRequestCode, mReplyCode)
        End Sub

        Public Class Request
            Public TrackingId As String
        End Class

        Friend Shared Function SendRequest(ByVal node As Framework.Net.Node, ByVal trackingId As String) As Integer
            Dim clsRequest As New Request
            clsRequest.TrackingId = trackingId

            Return node.SendCommandMessageAsync(mRequestCode, Framework.Serialization.ToXmlBytes(clsRequest))
        End Function

        Public Overrides Sub HandleRequest(ByVal envelope As Framework.Net.MessageEnvelope)
            Dim clsRequest As Request = Framework.Serialization.FromXmlBytes(Of Request)(envelope.Message.Message)

            TransferEngine.Manager.CancelUploadPartRequest(envelope.Node, clsRequest.TrackingId)
        End Sub

        Public Overrides Sub HandleReply(ByVal envelope As Framework.Net.MessageEnvelope)
            Throw New NotImplementedException
        End Sub
    End Class

End Namespace


